<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set> 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="shortcut icon" href="${ctx}/favicon.ico"> <link href="${ctx}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx}/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx}/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="${ctx}/css/animate.css" rel="stylesheet">
    <link href="${ctx}/css/style.css?v=4.1.0" rel="stylesheet">
</head>
<body>
       <div class="table-responsive" style="margin:2%;">
                <table class="table table-striped">
                    <thead>
                    <tr>
                    	<th>采购编号</th>
                        <th>商品名称</th>
                        <th>价格</th>
                        <th>规格</th>
                        <th>数量</th>
                        <th>采购人</th>
                        <th>厂商</th>
                        <th>备注</th>
                        <th>审核状态</th>
                        <th>采购时间</th>
                        <th>仓库</th>
                        <th>数据恢复</th>
                        <th>彻底清除</th>                        
                    </tr>
                    </thead>
                    <tbody> 
                    <c:forEach var="purchase" items="${purchaselist}">
                                <tr id="${purchase.purchase_id}">   
                                 	 <td >${purchase.purchase_id}</td>  
                                     <td>${purchase.goods_name}</td>
                                     <td>${purchase.price}</td>
                                     <td>${purchase.unit}</td>
                                     <td>${purchase.number}</td>
                                     <td>${purchase.purchase_name}</td>
                                     <td>${purchase.supplier_}</td>
                                     <td>${purchase.remark}</td>
                                     <td>${purchase.inspect}</td>
                                     <td>${purchase.purchase_time}</td>
                                     <td>${purchase.storehouse_name}</td>                                             
                                     <td>
                            			<a class="btn btn-primary btn-rounded" onclick="makeRegain(${purchase.purchase_id})">恢复</a>
                       				 </td>
                        			<td>
                            			<a class="btn btn-primary btn-rounded" onclick="makeDelete(${purchase.purchase_id})">清除</a>
                        			</td>
                                 </tr>
                    </c:forEach>                       
                    </tbody>
                </table>
            </div>
            <div>
                    <!-- <span style="float:left;">共25条数据5页</span> -->
                    <div id="page" style="text-align:right;"></div>
            </div>
</body>
<script src="${ctx}/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctx}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${ctx}/dist\layer-v3.1.1\layer\layer.js"></script>
<script src="${ctx}/dist/jquery-bootstrap-pagination/jquery-bootstrap-pagination.js"></script>
<script>
	//分页
    $("#page").pagination({
		  total_pages:${pageCount},
		  current_page:${pageNum},
		  prev: "上一页",
		  next: "下一页",
		  display_max:4,
		  callback: function(event, page) {
		      //return alert("Page " + page + " was clicked!");
		      location="${ctx}/RegainServlet/getPurchaseList?pageNum="+page;
		}
		});  
	//恢复
	function makeRegain(purchase_id){
		$.get('${ctx}/RegainServlet/regainPurchase',{'purchase_id':purchase_id},function(data){
    		if(data){
				layer.msg('恢复成功');
				//在页面表中删除数据
				document.getElementById(purchase_id).parentNode.removeChild(document.getElementById(purchase_id));
			}else{
				layer.msg('恢复失败');
			}
    	});    
	}
	//彻底删除
	function makeDelete(purchase_id){
		if(confirm('确定删除所选吗？')){
			$.get('${ctx}/RegainServlet/deletePurchase',{'purchase_id':purchase_id},function(data){
	    		if(data){
					layer.msg('清除成功');
					//在页面表中删除数据
					document.getElementById(purchase_id).parentNode.removeChild(document.getElementById(purchase_id));
				}else{
					layer.msg('清除失败');
				}
	    	});   
		}
	}
</script>
</html>